import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

void main() {
  runApp(GetMaterialApp(
    home: Myhomepage(),
  ));
}

class Myhomepage extends StatefulWidget {
  const Myhomepage({super.key});

  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return _MyHomePageState();
  }
}

class _MyHomePageState extends State<Myhomepage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('dialog'),
      ),
      body: Center(
        child: Column(
          children: [
            ElevatedButton(
                onPressed: () {
                  /// 从底部弹出来的弹chuang
                  Get.bottomSheet(Container(
                    color: Colors.white,
                    height: 200,
                    child: Column(
                      children: [
                        ListTile(
                          title: Text('选项1'),
                        ),
                        ListTile(
                          title: Text('选项2'),
                        ),
                        ListTile(
                          title: Text('选项3'),
                        ),
                      ],
                    ),
                  ));
                },
                child: const Text('Botton sheet')),
            ElevatedButton(
                onPressed: () {
                  /// 可以设置从顶部或者底部弹出类似于iOS消息推送动画那种弹窗
                  Get.snackbar(
                    '你好，标题',
                    '这是内容',
                    snackPosition: SnackPosition.TOP,
                    icon: Icon(Icons.ac_unit),
                  );
                },
                child: const Text('alert dialog窗窗')),

            /// 默认的弹窗
            ElevatedButton(
                onPressed: () {
                  /// 默认的弹chuang

                  Get.defaultDialog(title: '这是标题', content: const Text('这是内容'));
                },
                child: const Text('默认窗窗弹log')),
          ],
        ),
      ),
    );
  }
}

/// Getx使用dialog的详细说明
/// 1.使用统一的包装作为顶层，之前的MateriaApp替换成GetMaterialApp
/// 2.想使用的话，分别调用  Get.defaultDialog  、Get.snackbar  、Get.bottomSheet
/// 对应各自的属性参照内部
///
